import http from '../utils/http'
// 手机号码一键登录
export const getPhoneLogin = (data:any)=>{
  return http({
    method:"POST",
    url:'/mini/auth/getPhoneNumber',
    data,
  })
}
// 微信登录
export const getWeChatLogin = (data:any)=>{
  return http({
    method:"POST",
    url:`/mini/auth/wxlogin?code=${data.code}&userType=${data.userType}`,
  })
}
// 获取用户信息
export const getUserInfo = ()=>{
  return http({
    method:"GET",
    url:getApp().getUserType() === "01" ? '/teacher/instructor/getInfo' : `/mini/userInfo/getInfo`,
  })
}
// 获取教师信息
export const getTeacherInfo = ()=>{
  return http({
    method:"GET",
    url:`/teacher/instructor/getInfo`,
  })
}
// 获取用户详细信息
export const getUserInfoDetail = (data?:{userId?:number})=>{  
  return http({
    method:"GET",
    url:getApp().getUserType() === "01" ? `/teacher/instructor/getInfo` : `/user/parent/getInfo`,
    data
  })
}
// 获取验证码
export const sendcode = (data:{
  mobile:string
})=>{
  return http({
    method:'POST',
   url:`/mini/auth/sendcode?mobile=${data.mobile}`,
  })
}
// 教师端绑定手机号码
export const phoneVerify = (data:{
  code:string,
  openId:string,
  phone:string
})=>{
  return http({
    method:'POST',
   url:`/mini/auth/phoneVerify?code=${data.code}&openId=${data.openId}&phone=${data.phone}`,
  })
}
// 提交用户注册信息/修改用户注册信息
export const editInfo = (data:{
  nickName:string,
  sex:string
  idcard:string
  birthday:string
  phonenumber:string
  address:string
  inviteCode?:string
  schoolId?:string
})=>{
  return http({
    method:'POST',
    url:'/user/parent/edit',
    data
  })
}
// 保存用户名称与头像
export const saveAvatarAndName = (data:{
  avatar:string,
  nickName?:string
})=>{
  return http({
    method:'POST',
    url:`/mini/userInfo/updateNickNameAvatar?avatar=${data.avatar}&nickName=${data.nickName}`,
  })
}
//退出登录
export const exitLogin = ()=>{
  return http({
    method:'POST',
    url:`/mini/userInfo/logout`,
  })
}
